package com.ies.dx.dex.file;

import java.io.DataInputStream;

public class util
{
    
    public static int readUleb128(DataInputStream dis)
    {
        return 0;
    }
    
    public static void dumpbytes(byte[] bytes)
    {
        dumpbytes(bytes, 0, bytes.length);
    }

    public static void dumpbytes(byte[] bytes, int offset, int len)
    {
        int byteslen = offset + len;
        int l = bytes.length;
        String strln;

        if(offset > l)
            return;
        else if(byteslen > l)
            byteslen = l;
        
        
        for(int i = offset; i < byteslen; i+=16)
        {
            strln = hexstr(i, 8) + "  ";
            for(int j = 0; (j < 16)&&((i + j) < byteslen); j++)
                strln = strln + hexstr(bytes[i + j], 2) + " ";
            System.out.println(strln);
        }
    
    }
    
    public static String hexstr(int value, int strlen)
    {

        String istr = Integer.toHexString(value);
        int len = istr.length();

        if(len >= strlen)
            return istr.substring((len - strlen), len);
        else
        {
            for(int i = 0; i < (strlen - len); i++)
                istr = "0" + istr;
            return istr;
        }

    }

}
